Component({
  options: {
    styleIsolation: 'apply-shared'//页面样式将影响到组件,但组件中指定的样式不会影响页面
  },
  properties: {
    type:{
      type:String,
      value:''
    }
  },
  data: {
    isShow: false,//是否显示
    jobIntention: []
  },
  methods: {
    toPrivacy() {
      // 前往隐私协议页面
      wx.navigateTo({
        url: '/package/pages/privacyProtocol/privacyProtocol',
      })
    },
    toEntPrivacy() {
      // 前往用户协议页面
      wx.navigateTo({
        url: '/package/pages/companyUserProtocol/companyUserProtocol',
      })
    },
    toPersonPrivacy() {
      // 前往用户协议页面
      wx.navigateTo({
        url: '/package/pages/userProtocol/userProtocol',
      })
    },
    //显示弹窗
    showPicker(){
      this.setData({
        jobIntention: [],
        isShow: true,
      })
    },
    //隐藏弹窗
    protocolCancel() {
      this.setData({
        isShow: false,
      })
      // this.triggerEvent('comfirmProblem', { status: false })
    },
    comfirmVal2(e){
      let id = e.currentTarget.dataset.itemid
      let name = e.currentTarget.dataset.itemname
      let type = e.currentTarget.dataset.type
      let code = e.currentTarget.dataset.code
      let category = e.currentTarget.dataset.category || ''
      this.data.arrList.forEach(el => {
        if(el.code === code ) {
          if(!el.status) {
            el.status = true
            this.data.jobIntention.push(el)
          } else {
            el.status = false
            this.data.jobIntention.splice(this.data.jobIntention.indexOf(el),1)
          }
        }
      });
      this.setData({
        jobIntention: this.data.jobIntention,
        arrList:this.data.arrList
      })
    },
    enter(){
      this.setData({
        isShow: false,
      })
      this.triggerEvent('comfirm', this.data.jobIntention)
    },
    // 选中下拉选项
    comfirmVal(e){
      var id = e.currentTarget.dataset.itemid
      var name = e.currentTarget.dataset.itemname
      var type = e.currentTarget.dataset.type
      var code = e.currentTarget.dataset.code
      var category = e.currentTarget.dataset.category || ''
      this.setData({
        isShow: false,
      })
      if (type =='auditionPosition'){
        var salaryBegin = e.currentTarget.dataset.salarybegin
        var salaryEnd =e.currentTarget.dataset.salaryend
        var province = e.currentTarget.dataset.province
        var city = e.currentTarget.dataset.city
        var area = e.currentTarget.dataset.area
        var address = e.currentTarget.dataset.address
        this.triggerEvent('comfirmProblem', { status: true, id: id, name: name, type: type, salaryBegin: salaryBegin, salaryEnd: salaryEnd, province: province, city: city, area: area, address: address, })
      }else{
        this.triggerEvent('comfirmProblem', { status: true, id: id, name: name, type: type, code: code,category:category })
      }
    },
  }
})